package cn.db101.kaoqinserver.config;

import lombok.Data;

@Data
public class ApiResult<T> {

    private int code = 200;

    private String msg = "success";

    private T data;

    /**
     * 静态方法 ofSuccess返回成功的结果
     */
    public static <T> ApiResult<T> ofSuccess(T data) {
        ApiResult<T> result = new ApiResult<>();
        result.setData(data);
        return result;
    }

    /**
     * 静态方法 ofSuccess返回成功的结果
     */
    public static <T> ApiResult<T> ofSuccess() {
        ApiResult<T> result = new ApiResult<>();
        return result;
    }

    public static <T> ApiResult<T> ofError(int code, String msg) {
        ApiResult<T> result = new ApiResult<>();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }


}
